/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package core;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Keith
 */
@Entity
@Table(name = "_noteboardtbl")
@NamedQueries({
    @NamedQuery(name = "Noteboard.findAll", query = "SELECT n FROM Noteboard n"),
    @NamedQuery(name = "Noteboard.findByUser", query = "SELECT n FROM Noteboard n WHERE n.noteboardPK.user = :user"),
    @NamedQuery(name = "Noteboard.findById", query = "SELECT n FROM Noteboard n WHERE n.noteboardPK.id = :id")})
public class Noteboard implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected NoteboardPK noteboardPK;
    @Lob
    @Column(name = "_xml")
    private String xml;
    @JoinColumn(name = "_user", referencedColumnName = "_id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private User user1;

    public Noteboard() {
    }

    public Noteboard(NoteboardPK noteboardPK) {
        this.noteboardPK = noteboardPK;
    }

    public Noteboard(String user, String id) {
        this.noteboardPK = new NoteboardPK(user, id);
    }

    public NoteboardPK getNoteboardPK() {
        return noteboardPK;
    }

    public void setNoteboardPK(NoteboardPK noteboardPK) {
        this.noteboardPK = noteboardPK;
    }

    public String getXml() {
        return xml;
    }

    public void setXml(String xml) {
        this.xml = xml;
    }

    public User getUser1() {
        return user1;
    }

    public void setUser1(User user1) {
        this.user1 = user1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (noteboardPK != null ? noteboardPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Noteboard)) {
            return false;
        }
        Noteboard other = (Noteboard) object;
        if ((this.noteboardPK == null && other.noteboardPK != null) || (this.noteboardPK != null && !this.noteboardPK.equals(other.noteboardPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "core.Noteboard[noteboardPK=" + noteboardPK + "]";
    }

}
